
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>openSLES · Aivin开发笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Aivin">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-versions-select/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="openSLES基础.html" />
    
    
    <link rel="prev" href="../opencv/opencv.html" />
    

    
        <link rel="shortcut icon" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    项目说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../linux/linux基础.html">
            
                <a href="../linux/linux基础.html">
            
                    
                    linux
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../linux/linux基础.html">
            
                <a href="../linux/linux基础.html">
            
                    
                    linux基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../linux/android底层开发.html">
            
                <a href="../linux/android底层开发.html">
            
                    
                    android底层开发
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../c语言/c基础.html">
            
                <a href="../c语言/c基础.html">
            
                    
                    c
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../c语言/c基础.html">
            
                <a href="../c语言/c基础.html">
            
                    
                    c基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../c++/c++基础.html">
            
                <a href="../c++/c++基础.html">
            
                    
                    c++
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../c++/c++基础.html">
            
                <a href="../c++/c++基础.html">
            
                    
                    c++基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../QT/QT基础.html">
            
                <a href="../QT/QT基础.html">
            
                    
                    QT
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../QT/QT基础.html">
            
                <a href="../QT/QT基础.html">
            
                    
                    QT基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../jni/JNI基础.html">
            
                <a href="../jni/JNI基础.html">
            
                    
                    JNI
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../jni/JNI基础.html">
            
                <a href="../jni/JNI基础.html">
            
                    
                    JNI基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../jni/JNI例子.html">
            
                <a href="../jni/JNI例子.html">
            
                    
                    JNI例子
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../SDL/SDL基础.html">
            
                <a href="../SDL/SDL基础.html">
            
                    
                    SDL
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../SDL/SDL基础.html">
            
                <a href="../SDL/SDL基础.html">
            
                    
                    SDL基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../ffmpeg/ffmpeg基础.html">
            
                <a href="../ffmpeg/ffmpeg基础.html">
            
                    
                    ffmpeg
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../ffmpeg/ffmpeg基础.html">
            
                <a href="../ffmpeg/ffmpeg基础.html">
            
                    
                    ffmpeg基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../ffmpeg/ffmpeg示例代码.html">
            
                <a href="../ffmpeg/ffmpeg示例代码.html">
            
                    
                    ffmpeg示例代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../ffmpeg/ffmpeg软解rtsp简单直播.html">
            
                <a href="../ffmpeg/ffmpeg软解rtsp简单直播.html">
            
                    
                    ffmpeg软解rtsp简单直播
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../ffmpeg/rtsp服务器.html">
            
                <a href="../ffmpeg/rtsp服务器.html">
            
                    
                    rtsp服务器Windows
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../opencv/opencv模块.html">
            
                <a href="../opencv/opencv模块.html">
            
                    
                    opencv模块
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../opencv/opencv.html">
            
                <a href="../opencv/opencv.html">
            
                    
                    opencv
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter active" data-level="1.10" data-path="openSLES基础.html">
            
                <a href="openSLES基础.html">
            
                    
                    openSLES
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.10.1" data-path="openSLES基础.html">
            
                <a href="openSLES基础.html">
            
                    
                    openSLES基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../SoundTouch/移植SoundTouch.html">
            
                <a href="../SoundTouch/移植SoundTouch.html">
            
                    
                    SoundTouch
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../SoundTouch/移植SoundTouch.html">
            
                <a href="../SoundTouch/移植SoundTouch.html">
            
                    
                    移植SoundTouch
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../SoundTouch/实现音频变速和变调.html">
            
                <a href="../SoundTouch/实现音频变速和变调.html">
            
                    
                    实现音频变速和变调
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../openGLES/openGLES基础.html">
            
                <a href="../openGLES/openGLES基础.html">
            
                    
                    openGLES模块
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../openGLES/openGLES基础.html">
            
                <a href="../openGLES/openGLES基础.html">
            
                    
                    openGLES基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../openGLES/GLSL基础.html">
            
                <a href="../openGLES/GLSL基础.html">
            
                    
                    GLSL基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../openGLES/openglES示例.html">
            
                <a href="../openGLES/openglES示例.html">
            
                    
                    openglES示例
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../视频相关/音视频基础.html">
            
                <a href="../视频相关/音视频基础.html">
            
                    
                    音视频术语-文件格式-协议
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../视频相关/音视频基础.html">
            
                <a href="../视频相关/音视频基础.html">
            
                    
                    音视频基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../视频相关/RTSP.html">
            
                <a href="../视频相关/RTSP.html">
            
                    
                    RTSP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="../视频相关/RTP.html">
            
                <a href="../视频相关/RTP.html">
            
                    
                    RTP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.4" data-path="../视频相关/RTCP.html">
            
                <a href="../视频相关/RTCP.html">
            
                    
                    RTCP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.5" data-path="../视频相关/H264.html">
            
                <a href="../视频相关/H264.html">
            
                    
                    H264
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.6" data-path="../视频相关/YUV.html">
            
                <a href="../视频相关/YUV.html">
            
                    
                    YUV
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.7" data-path="../视频相关/SurfaceView.html">
            
                <a href="../视频相关/SurfaceView.html">
            
                    
                    SurfaceView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.8" data-path="../视频相关/RTMP.html">
            
                <a href="../视频相关/RTMP.html">
            
                    
                    RTMP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.9" data-path="../视频相关/AAC详解.html">
            
                <a href="../视频相关/AAC详解.html">
            
                    
                    AAC详解
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../音视频相关代码/音视频相关代码.html">
            
                <a href="../音视频相关代码/音视频相关代码.html">
            
                    
                    音视频相关代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../ndk/NDK编译基础.html">
            
                <a href="../ndk/NDK编译基础.html">
            
                    
                    NDK工程编译
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.1" data-path="../ndk/NDK编译基础.html">
            
                <a href="../ndk/NDK编译基础.html">
            
                    
                    NDK编译基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2" data-path="../ndk/cmake方式.html">
            
                <a href="../ndk/cmake方式.html">
            
                    
                    cmake
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3" data-path="../ndk/Android.mk模板.html">
            
                <a href="../ndk/Android.mk模板.html">
            
                    
                    Android.mk
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4" data-path="../ndk/Application.mk模板.html">
            
                <a href="../ndk/Application.mk模板.html">
            
                    
                    Application.mk
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >openSLES</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#opensles"><b>1. </b>openSLES</a></li><ul><li><span class="title-icon "></span><a href="#opensl-es-&#x5E38;&#x7528;&#x529F;&#x80FD;"><b>1.1. </b>OPenSL ES &#x5E38;&#x7528;&#x529F;&#x80FD;</a></li><li><span class="title-icon "></span><a href="#opensl-es-&#x7684;&#x7F3A;&#x70B9;"><b>1.2. </b>OPenSL ES &#x7684;&#x7F3A;&#x70B9;</a></li><li><span class="title-icon "></span><a href="#opensl-es-&#x72B6;&#x6001;&#x673A;&#x5236;"><b>1.3. </b>OPenSL ES &#x72B6;&#x6001;&#x673A;&#x5236;</a></li><li><span class="title-icon "></span><a href="#opensl-es-&#x91CD;&#x8981;&#x6982;&#x5FF5;-&#xFF1A;-objects-&#x548C;-interfaces"><b>1.4. </b>OPenSL ES &#x91CD;&#x8981;&#x6982;&#x5FF5; &#xFF1A; Objects &#x548C; Interfaces</a></li><li><span class="title-icon "></span><a href="#&#x5E38;&#x7528;&#x7684;&#x63A5;&#x53E3;"><b>1.5. </b>&#x5E38;&#x7528;&#x7684;&#x63A5;&#x53E3;</a></li><ul><li><span class="title-icon "></span><a href="#&#x5F15;&#x64CE;&#x63A5;&#x53E3;--slengineitf"><b>1.5.1. </b>&#x5F15;&#x64CE;&#x63A5;&#x53E3;  SLEngineItf</a></li></ul><li><span class="title-icon "></span><a href="#&#x6DF7;&#x97F3;&#x5668;"><b>1.6. </b>&#x6DF7;&#x97F3;&#x5668;</a></li><ul><li><span class="title-icon "></span><a href="#&#x5E38;&#x7528;&#x51FD;&#x6570;"><b>1.6.1. </b>&#x5E38;&#x7528;&#x51FD;&#x6570;</a></li><li><span class="title-icon "></span><a href="#&#x5E38;&#x7528;&#x7C7B;&#x548C;&#x5E38;&#x91CF;"><b>1.6.2. </b>&#x5E38;&#x7528;&#x7C7B;&#x548C;&#x5E38;&#x91CF;</a></li></ul><li><span class="title-icon "></span><a href="#&#x64AD;&#x653E;&#x5668;"><b>1.7. </b>&#x64AD;&#x653E;&#x5668;</a></li><li><span class="title-icon "></span><a href="#&#x4F7F;&#x7528;-opensl-es-&#x6D41;&#x7A0B;"><b>1.8. </b>&#x4F7F;&#x7528; OPenSL ES &#x6D41;&#x7A0B;</a></li><li><span class="title-icon "></span><a href="#androidstudio-&#x914D;&#x7F6E;-opengsl-es"><b>1.9. </b>androidStudio &#x914D;&#x7F6E; opengSL ES</a></li><ul><li><span class="title-icon "></span><a href="#&#x58F0;&#x9053;&#x5207;&#x6362;"><b>1.9.1. </b>&#x58F0;&#x9053;&#x5207;&#x6362;</a></li><li><span class="title-icon "></span><a href="#&#x6682;&#x505C;&#x3001;&#x64AD;&#x653E;"><b>1.9.2. </b>&#x6682;&#x505C;&#x3001;&#x64AD;&#x653E;</a></li><li><span class="title-icon "></span><a href="#seek-&#x4FEE;&#x6539;&#x64AD;&#x653E;&#x8FDB;&#x5EA6;"><b>1.9.3. </b>seek &#x4FEE;&#x6539;&#x64AD;&#x653E;&#x8FDB;&#x5EA6;</a></li><li><span class="title-icon "></span><a href="#&#x4FEE;&#x6539;&#x97F3;&#x91CF;"><b>1.9.4. </b>&#x4FEE;&#x6539;&#x97F3;&#x91CF;</a></li><li><span class="title-icon "></span><a href="#&#x8FB9;&#x64AD;&#x8FB9;&#x5F55;"><b>1.9.5. </b>&#x8FB9;&#x64AD;&#x8FB9;&#x5F55;</a></li><li><span class="title-icon "></span><a href="#&#x6C42;pcm&#x7684;&#x5206;&#x8D1D;&#x503C;"><b>1.9.6. </b>&#x6C42;PCM&#x7684;&#x5206;&#x8D1D;&#x503C;</a></li></ul></ul></ul></div><a href="#opensles" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="opensles"><a name="opensles" class="anchor-navigation-ex-anchor" href="#opensles"><i class="fa fa-link" aria-hidden="true"></i></a>1. openSLES</h1>
<pre><code class="lang-xml">OpenSL ES (Open Sound Library for Embedded Systems)
C &#x8BED;&#x8A00;&#x63A5;&#x53E3;&#xFF0C;&#x517C;&#x5BB9; C++ &#x3002;
&#x662F;&#x4E00;&#x4E2A;&#x5D4C;&#x5165;&#x5F0F;&#x3001;&#x8DE8;&#x5E73;&#x53F0;&#x3001;&#x514D;&#x8D39;&#x7684;&#x3001;&#x97F3;&#x9891;&#x5904;&#x7406;&#x5E93;&#x3002;

android NDK &#x5DF2;&#x7ECF;&#x5185;&#x5D4C;&#xFF0C;
&#x4F4D;&#x4E8E;&#x7C7B;&#x4F3C; xxx\ndk-bundle\platforms\android-9\arch-x86\usr\lib

Android 2.3 (API 9) &#x5F00;&#x59CB;&#x652F;&#x6301; OpenSL ES &#x6807;&#x51C6;&#xFF0C;
Android&#x5B9E;&#x73B0;&#x7684; OpenSL ES &#x53EA;&#x662F; OpenSL 1.0.1 &#x7684;&#x5B50;&#x96C6;&#xFF0C;&#x5E76;&#x4E14;&#x8FDB;&#x884C;&#x4E86;&#x6269;&#x5C55;&#x3002;
</code></pre>
<h2 id="opensl-es-&#x5E38;&#x7528;&#x529F;&#x80FD;"><a name="opensl-es-&#x5E38;&#x7528;&#x529F;&#x80FD;" class="anchor-navigation-ex-anchor" href="#opensl-es-&#x5E38;&#x7528;&#x529F;&#x80FD;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. OPenSL ES &#x5E38;&#x7528;&#x529F;&#x80FD;</h2>
<pre><code class="lang-c++"><span class="hljs-number">1</span>&#x3001;&#x652F;&#x6301; PCM &#x6570;&#x636E;&#x7684;&#x91C7;&#x96C6;
&#x652F;&#x6301;&#x7684;&#x914D;&#x7F6E;&#xFF1A;<span class="hljs-number">16</span>bit &#x4F4D;&#x5BBD;&#xFF0C;<span class="hljs-number">16000</span> Hz&#x91C7;&#x6837;&#x7387;&#xFF0C;&#x5355;&#x901A;&#x9053;&#x3002;&#xFF08;&#x5176;&#x4ED6;&#x7684;&#x914D;&#x7F6E;&#x4E0D;&#x80FD;&#x4FDD;&#x8BC1;&#x517C;&#x5BB9;&#x6240;&#x6709;&#x5E73;&#x53F0;&#xFF09;

<span class="hljs-number">2</span>&#x3001;&#x652F;&#x6301; PCM &#x6570;&#x636E;&#x7684;&#x64AD;&#x653E;
&#x652F;&#x6301;&#x7684;&#x914D;&#x7F6E;&#xFF1A;<span class="hljs-number">8</span>bit/<span class="hljs-number">16</span>bit &#x4F4D;&#x5BBD;&#xFF0C;&#x5355;&#x901A;&#x9053;/&#x53CC;&#x901A;&#x9053;&#xFF0C;&#x5C0F;&#x7AEF;&#x6A21;&#x5F0F;&#xFF0C;
&#x91C7;&#x6837;&#x7387;&#xFF08;<span class="hljs-number">8000</span>, <span class="hljs-number">11025</span>, <span class="hljs-number">12000</span>, <span class="hljs-number">16000</span>, <span class="hljs-number">22050</span>, <span class="hljs-number">24000</span>, <span class="hljs-number">32000</span>, <span class="hljs-number">44100</span>, <span class="hljs-number">48000</span> Hz&#xFF09;

<span class="hljs-number">3</span>&#x3001;&#x652F;&#x6301;&#x64AD;&#x653E;&#x7684;&#x97F3;&#x9891;&#x6570;&#x636E;&#x6765;&#x6E90;&#xFF1A;
res &#x6587;&#x4EF6;&#x5939;&#x4E0B;&#x7684;&#x97F3;&#x9891;&#x3001;
assets &#x6587;&#x4EF6;&#x5939;&#x4E0B;&#x7684;&#x97F3;&#x9891;&#x3001;
sdcard &#x76EE;&#x5F55;&#x4E0B;&#x7684;&#x97F3;&#x9891;&#x3001;
&#x5728;&#x7EBF;&#x7F51;&#x7EDC;&#x97F3;&#x9891;&#x3001;
&#x4EE3;&#x7801;&#x4E2D;&#x5B9A;&#x4E49;&#x7684;&#x97F3;&#x9891;&#x4E8C;&#x8FDB;&#x5236;&#x6570;&#x636E;&#x7B49;
</code></pre>
<h2 id="opensl-es-&#x7684;&#x7F3A;&#x70B9;"><a name="opensl-es-&#x7684;&#x7F3A;&#x70B9;" class="anchor-navigation-ex-anchor" href="#opensl-es-&#x7684;&#x7F3A;&#x70B9;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2. OPenSL ES &#x7684;&#x7F3A;&#x70B9;</h2>
<pre><code class="lang-c++"><span class="hljs-number">1</span>&#x3001;&#x4E0D;&#x652F;&#x6301;&#x7248;&#x672C;&#x4F4E;&#x4E8E; Android <span class="hljs-number">2.3</span> (API <span class="hljs-number">9</span>) &#x7684;&#x8BBE;&#x5907;
<span class="hljs-number">2</span>&#x3001;&#x6CA1;&#x6709;&#x5168;&#x90E8;&#x5B9E;&#x73B0; OpenSL ES &#x5B9A;&#x4E49;&#x7684;&#x7279;&#x6027;&#x548C;&#x529F;&#x80FD;
<span class="hljs-number">3</span>&#x3001;&#x4E0D;&#x652F;&#x6301; MIDI
<span class="hljs-number">4</span>&#x3001;&#x4E0D;&#x652F;&#x6301;&#x76F4;&#x63A5;&#x64AD;&#x653E; DRM &#x6216;&#x8005; &#x52A0;&#x5BC6;&#x7684;&#x5185;&#x5BB9;
<span class="hljs-number">5</span>&#x3001;&#x4E0D;&#x652F;&#x6301;&#x97F3;&#x9891;&#x6570;&#x636E;&#x7684;&#x7F16;&#x89E3;&#x7801;
</code></pre>
<h2 id="opensl-es-&#x72B6;&#x6001;&#x673A;&#x5236;"><a name="opensl-es-&#x72B6;&#x6001;&#x673A;&#x5236;" class="anchor-navigation-ex-anchor" href="#opensl-es-&#x72B6;&#x6001;&#x673A;&#x5236;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3. OPenSL ES &#x72B6;&#x6001;&#x673A;&#x5236;</h2>
<pre><code class="lang-c++"><span class="hljs-number">1</span>&#x3001;&#x4EFB;&#x4F55;&#x4E00;&#x4E2A; OpenSL ES &#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x521B;&#x5EFA;&#x6210;&#x529F;&#x540E;&#xFF0C;&#x90FD;&#x8FDB;&#x5165; SL_OBJECT_STATE_UNREALIZED &#x72B6;&#x6001;&#xFF0C;
&#x8FD9;&#x79CD;&#x72B6;&#x6001;&#x4E0B;&#xFF0C;&#x7CFB;&#x7EDF;&#x4E0D;&#x4F1A;&#x4E3A;&#x5B83;&#x5206;&#x914D;&#x4EFB;&#x4F55;&#x8D44;&#x6E90;&#xFF0C;&#x76F4;&#x5230;&#x8C03;&#x7528; Realize &#x51FD;&#x6570;&#x4E3A;&#x6B62;&#x3002;

<span class="hljs-number">2</span>&#x3001;Realize &#x540E;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x5C31;&#x4F1A;&#x8FDB;&#x5165; SL_OBJECT_STATE_REALIZED &#x72B6;&#x6001;&#xFF0C;
&#x8FD9;&#x662F;&#x4E00;&#x79CD;&#x201C;&#x53EF;&#x7528;&#x201D;&#x7684;&#x72B6;&#x6001;&#xFF0C;&#x53EA;&#x6709;&#x5728;&#x8FD9;&#x79CD;&#x72B6;&#x6001;&#x4E0B;&#xFF0C;&#x5BF9;&#x8C61;&#x7684;&#x5404;&#x4E2A;&#x529F;&#x80FD;&#x548C;&#x8D44;&#x6E90;&#x624D;&#x80FD;&#x6B63;&#x5E38;&#x5730;&#x8BBF;&#x95EE;&#x3002;

<span class="hljs-number">3</span>&#x3001;&#x5F53;&#x4E00;&#x4E9B;&#x7CFB;&#x7EDF;&#x4E8B;&#x4EF6;&#x53D1;&#x751F;&#x540E;&#xFF0C;&#x6BD4;&#x5982;&#x51FA;&#x73B0;&#x9519;&#x8BEF;&#x6216;&#x8005; Audio &#x8BBE;&#x5907;&#x88AB;&#x5176;&#x4ED6;&#x5E94;&#x7528;&#x62A2;&#x5360;&#xFF0C;
OpenSL ES &#x5BF9;&#x8C61;&#x4F1A;&#x8FDB;&#x5165; SL_OBJECT_STATE_SUSPENDED &#x72B6;&#x6001;&#xFF0C;
&#x5982;&#x679C;&#x5E0C;&#x671B;&#x6062;&#x590D;&#x6B63;&#x5E38;&#x4F7F;&#x7528;&#xFF0C;&#x9700;&#x8981;&#x8C03;&#x7528; Resume &#x51FD;&#x6570;&#x3002;

<span class="hljs-number">4</span>&#x3001;&#x5F53;&#x8C03;&#x7528;&#x5BF9;&#x8C61;&#x7684; Destroy &#x51FD;&#x6570;&#x540E;&#xFF0C;&#x5219;&#x4F1A;&#x91CA;&#x653E;&#x8D44;&#x6E90;&#xFF0C;
&#x5E76;&#x56DE;&#x5230; SL_OBJECT_STATE_UNREALIZED &#x72B6;&#x6001;&#x3002;
</code></pre>
<h2 id="opensl-es-&#x91CD;&#x8981;&#x6982;&#x5FF5;-&#xFF1A;-objects-&#x548C;-interfaces"><a name="opensl-es-&#x91CD;&#x8981;&#x6982;&#x5FF5;-&#xFF1A;-objects-&#x548C;-interfaces" class="anchor-navigation-ex-anchor" href="#opensl-es-&#x91CD;&#x8981;&#x6982;&#x5FF5;-&#xFF1A;-objects-&#x548C;-interfaces"><i class="fa fa-link" aria-hidden="true"></i></a>1.4. OPenSL ES &#x91CD;&#x8981;&#x6982;&#x5FF5; &#xFF1A; Objects &#x548C; Interfaces</h2>
<pre><code class="lang-c++"><span class="hljs-number">1</span>&#x3001;&#x6BCF;&#x4E2A; Object &#x53EF;&#x80FD;&#x4F1A;&#x5B58;&#x5728;&#x4E00;&#x4E2A;&#x6216;&#x8005;&#x591A;&#x4E2A; Interface&#xFF0C;
&#x5B98;&#x65B9;&#x4E3A;&#x6BCF;&#x4E00;&#x79CD; Object &#x90FD;&#x5B9A;&#x4E49;&#x4E86;&#x4E00;&#x7CFB;&#x5217;&#x7684; Interface

<span class="hljs-number">2</span>&#x3001;&#x6BCF;&#x4E2A; Object &#x5BF9;&#x8C61;&#x90FD;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E9B;&#x6700;&#x57FA;&#x7840;&#x7684;&#x64CD;&#x4F5C; &#x6BD4;&#x5982;&#xFF1A;Realize &#x3001;Destroy &#x7B49;&#x7B49;&#xFF0C;
&#x4F46;&#x662F;&#x60F3;&#x4F7F;&#x7528;&#x8BE5;&#x5BF9;&#x8C61;&#x652F;&#x6301;&#x7684;&#x529F;&#x80FD;&#x51FD;&#x6570;&#xFF0C;&#x5219;&#x5FC5;&#x987B;&#x901A;&#x8FC7;&#x5176; GetInterface &#x51FD;&#x6570;&#x62FF;&#x5230; Interface &#x63A5;&#x53E3;&#xFF0C;
&#x7136;&#x540E;&#x901A;&#x8FC7; Interface &#x6765;&#x8BBF;&#x95EE;&#x529F;&#x80FD;&#x51FD;&#x6570; &#x3002;

<span class="hljs-number">3</span>&#x3001;&#x5FC3;&#x4E2D;&#x4FDD;&#x6301;&#x4E00;&#x4E2A;&#x6982;&#x5FF5;&#xFF0C;&#x5C31;&#x662F;&#x5728; OpenSL ES &#x4E2D;&#xFF0C;&#x4E00;&#x5207; API &#x7684;&#x8BBF;&#x95EE;&#x548C;&#x63A7;&#x5236;&#x90FD;&#x662F;&#x901A;&#x8FC7; Interface &#x6765;&#x5B8C;&#x6210;&#x7684;&#x3002;
&#x4EE5;&#x5F15;&#x64CE;&#x63A5;&#x53E3;&#x4E3A;&#x4F8B;&#xFF1A;
&#x2460;&#x3001;&#x5148;&#x901A;&#x8FC7; SLObjectItf &#x83B7;&#x5F97; &#x5F15;&#x64CE;&#x5BF9;&#x8C61;
&#x2461;&#x3001;&#x518D;&#x901A;&#x8FC7; &#x5F15;&#x64CE;&#x5BF9;&#x8C61; &#x83B7;&#x5F97; &#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;&#x5BF9;&#x5E94;&#x7684;&#x5F15;&#x64CE;&#x63A5;&#x53E3;&#x3002;
&#x2462;&#x3001;&#x6700;&#x540E;&#x901A;&#x8FC7;&#x8FD9;&#x4E2A;&#x5F15;&#x64CE;&#x63A5;&#x53E3;&#x5B9E;&#x73B0;&#x5177;&#x4F53;&#x529F;&#x80FD;&#x3002;
</code></pre>
<p><br></p>
<h2 id="&#x5E38;&#x7528;&#x7684;&#x63A5;&#x53E3;"><a name="&#x5E38;&#x7528;&#x7684;&#x63A5;&#x53E3;" class="anchor-navigation-ex-anchor" href="#&#x5E38;&#x7528;&#x7684;&#x63A5;&#x53E3;"><i class="fa fa-link" aria-hidden="true"></i></a>1.5. &#x5E38;&#x7528;&#x7684;&#x63A5;&#x53E3;</h2>
<p>&#x5728;OpenSL ES&#x4E2D;&#x6240;&#x6709;&#x7684;&#x64CD;&#x4F5C;&#x90FD;&#x662F;&#x901A;&#x8FC7;&#x63A5;&#x53E3;&#x6765;&#x5B8C;&#x6210;&#xFF0C;&#x548C;java&#x7684;&#x63A5;&#x53E3;&#x7C7B;&#x4F3C;&#xFF0C;&#x63A5;&#x53E3;&#x63D0;&#x4F9B;&#x5E95;&#x5C42;&#x7684;&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x3002;</p>
<pre><code class="lang-c++">SLObjectItf &#xFF1A;&#x5BF9;&#x8C61;&#x63A5;&#x53E3;
SLEngineItf &#xFF1A;&#x5F15;&#x64CE;&#x63A5;&#x53E3;
SLPlayItf&#xFF1A;&#x64AD;&#x653E;&#x63A5;&#x53E3;
SLBufferQueueItf :&#x7F13;&#x51B2;&#x961F;&#x5217;&#x63A5;&#x53E3;
SLVolumeItf : &#x58F0;&#x91CF;&#x63A5;&#x53E3;
</code></pre>
<h3 id="&#x5F15;&#x64CE;&#x63A5;&#x53E3;--slengineitf"><a name="&#x5F15;&#x64CE;&#x63A5;&#x53E3;--slengineitf" class="anchor-navigation-ex-anchor" href="#&#x5F15;&#x64CE;&#x63A5;&#x53E3;--slengineitf"><i class="fa fa-link" aria-hidden="true"></i></a>1.5.1. &#x5F15;&#x64CE;&#x63A5;&#x53E3;  SLEngineItf</h3>
<pre><code class="lang-c++"><span class="hljs-comment">// &#x5F15;&#x64CE;&#x5BF9;&#x8C61;</span>
SLObjectItf engineObject = <span class="hljs-literal">NULL</span>;
<span class="hljs-comment">// &#x521B;&#x5EFA;&#x5BF9;&#x8C61;</span>
SLresult result = slCreateEngine(&amp;engineObject, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>);
<span class="hljs-comment">//&#x521D;&#x59CB;&#x5316;&#x5BF9;&#x8C61;</span>
SLresult result2 = (*engineObject)-&gt;Realize(engineObject, SL_BOOLEAN_FALSE);
<span class="hljs-comment">// &#x9500;&#x6BC1;&#x5BF9;&#x8C61;</span>
(*engineObject)-&gt;Destroy(engineObject);

<span class="hljs-comment">// &#x5F15;&#x64CE;&#x63A5;&#x53E3;</span>
SLEngineItf engineEngine = <span class="hljs-literal">NULL</span>;
<span class="hljs-comment">// &#x83B7;&#x53D6;&#x5BF9;&#x8C61;&#x7684;&#x529F;&#x80FD;&#x63A5;&#x53E3;</span>
SLresult result3 = (*engineObject)-&gt;GetInterface(engineObject, SL_IID_ENGINE, &amp;engineEngine);
<span class="hljs-comment">// &#x8C03;&#x7528;&#x63A5;&#x53E3;&#x5B9E;&#x73B0;&#x5177;&#x4F53;&#x529F;&#x80FD; &#xFF0C;&#x4F8B;&#x5982; &#x521B;&#x5EFA;&#x97F3;&#x9891;&#x64AD;&#x653E;&#x5668;&#x5BF9;&#x8C61;</span>
SLresult result4 = (*engineEngine)-&gt;CreateAudioPlayer(engineEngine, &amp;pcmPlayerObject, &amp;slDataSource, &amp;audioSnk, <span class="hljs-number">3</span>, ids, req);
</code></pre>
<p><br></p>
<h2 id="&#x6DF7;&#x97F3;&#x5668;"><a name="&#x6DF7;&#x97F3;&#x5668;" class="anchor-navigation-ex-anchor" href="#&#x6DF7;&#x97F3;&#x5668;"><i class="fa fa-link" aria-hidden="true"></i></a>1.6. &#x6DF7;&#x97F3;&#x5668;</h2>
<pre><code class="lang-c++"><span class="hljs-comment">//&#x6DF7;&#x97F3;&#x5668;&#x5BF9;&#x8C61;</span>
SLObjectItf outputMixObject = <span class="hljs-literal">NULL</span>;
<span class="hljs-comment">//&#x521B;&#x5EFA;&#x6DF7;&#x97F3;&#x5668;&#x5BF9;&#x8C61;</span>
SLresult result = (*engineEngine)-&gt;CreateOutputMix(engineEngine, &amp;outputMixObject, <span class="hljs-number">1</span>, mids, mreq);
<span class="hljs-comment">//&#x5B9E;&#x73B0;&#x6DF7;&#x97F3;&#x5668;&#x5BF9;&#x8C61;</span>
result = (*outputMixObject)-&gt;Realize(outputMixObject, SL_BOOLEAN_FALSE);
<span class="hljs-comment">// &#x8DDF;&#x8FDB;&#x5BF9;&#x8C61;&#x83B7;&#x53D6;&#x5BF9;&#x5E94;&#x7684;&#x529F;&#x80FD;&#x63A5;&#x53E3;</span>
result = (*outputMixObject)-&gt;GetInterface(outputMixObject, SL_IID_ENVIRONMENTALREVERB, &amp;outputMixEnvironmentalReverb);
</code></pre>
<h3 id="&#x5E38;&#x7528;&#x51FD;&#x6570;"><a name="&#x5E38;&#x7528;&#x51FD;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x5E38;&#x7528;&#x51FD;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>1.6.1. &#x5E38;&#x7528;&#x51FD;&#x6570;</h3>
<pre><code class="lang-text">SetPlayState () // &#x8BBE;&#x7F6E;&#x64AD;&#x653E;&#x5668;&#x72B6;&#x6001;
slCreateEngine () // &#x521B;&#x5EFA;&#x5BF9;&#x8C61;
Realize () //  &#x5206;&#x914D;&#x8D44;&#x6E90;
GetInterface () // &#x901A;&#x8FC7;&#x5BF9;&#x8C61;&#xFF0C;&#x62FF;&#x5230;&#x63A5;&#x53E3;
CreateOutputMix () // &#x521B;&#x5EFA;&#x6DF7;&#x97F3;&#x5668;
SetEnvironmentalReverbProperties () //
CreateAudioPlayer() // &#x521B;&#x5EFA;&#x64AD;&#x653E;&#x5668;
</code></pre>
<h3 id="&#x5E38;&#x7528;&#x7C7B;&#x548C;&#x5E38;&#x91CF;"><a name="&#x5E38;&#x7528;&#x7C7B;&#x548C;&#x5E38;&#x91CF;" class="anchor-navigation-ex-anchor" href="#&#x5E38;&#x7528;&#x7C7B;&#x548C;&#x5E38;&#x91CF;"><i class="fa fa-link" aria-hidden="true"></i></a>1.6.2. &#x5E38;&#x7528;&#x7C7B;&#x548C;&#x5E38;&#x91CF;</h3>
<pre><code class="lang-text">SLEnvironmentalReverbItf       //  &#x4E00;&#x4E2A;&#x7ED3;&#x6784;&#x4F53; &#xFF0C;
SLEnvironmentalReverbSettings  // &#x4E00;&#x4E2A;&#x7ED3;&#x6784;&#x4F53; &#xFF0C;
SLAndroidSimpleBufferQueueItf  // &#x961F;&#x5217;
SLInterfaceID  //
SLDataLocator_OutputMix  //
SLDataSink //
SLDataSource // 

nb_samples // &#x6BCF;&#x4E2A;&#x8F68;&#x9053;&#x7684;&#x6837;&#x672C;&#x6570;
channels   //&#x97F3;&#x9891;&#x901A;&#x9053;&#x6570;
channel_layout // &#x97F3;&#x9891;&#x901A;&#x9053;&#x683C;&#x5F0F;&#x7C7B;&#x578B; ,&#x5982; &#x5355;&#x901A;&#x9053; &#x53CC;&#x901A;&#x9053;
sample_rate    // &#x91C7;&#x6837;&#x7387;&#xFF0C;Audio only. The number of bytes per coded audio frame
AV_SAMPLE_FMT_S16     //  &#x4E00;&#x79CD;&#x97F3;&#x9891;&#x683C;&#x5F0F;
AV_CH_LAYOUT_STEREO   // &#x53CC;&#x58F0;&#x9053;
AV_CH_LAYOUT_SURROUND // &#x4E09;&#x58F0;&#x9053;

SL_DATALOCATOR_OUTPUTMIX //  0x00000004
SLDataLocator_AndroidSimpleBufferQueue  //
SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE //
SLDataFormat_PCM // 
SL_DATAFORMAT_PCM //  pcm&#x683C;&#x5F0F;&#x7684;&#x6570;&#x636E;
SL_PCMSAMPLEFORMAT_FIXED_16 //   &#x4F4D;&#x6570;16&#x4F4D;
SL_SPEAKER_FRONT_LEFT       //  &#x7ACB;&#x4F53;&#x58F0;,&#x524D;&#x5DE6;
SL_SPEAKER_FRONT_RIGHT     //&#x7ACB;&#x4F53;&#x58F0; ,&#x524D;&#x53F3;
SL_BYTEORDER_LITTLEENDIAN   // 
SL_PLAYSTATE_PAUSED  // glsl&#x7684;&#x6682;&#x505C;&#x72B6;&#x6001;&#x5E38;&#x91CF;
SL_PLAYSTATE_STOPPED //
SL_PLAYSTATE_PLAYING //
SL_IID_BUFFERQUEUE // 
SL_IID_PLAYBACKRATE //
SL_RESULT_SUCCESS  // 0
SL_BOOLEAN_FALSE  //false 
SL_BOOLEAN_TRUE //
SL_IID_ENGINE  // &#x4E00;&#x4E2A;&#x5E38;&#x91CF;&#xFF0C;&#x83B7;&#x53D6;&#x63A5;&#x53E3;&#x7528;&#x5230;
SL_IID_ENVIRONMENTALREVERB // 
SL_IID_PLAY  //
SL_SAMPLINGRATE_8  // opensl&#x4E2D;&#x7684;&#x91C7;&#x6837;&#x7387;&#x5E38;&#x91CF;
SL_SAMPLINGRATE_11_025
SL_SAMPLINGRATE_12    
SL_SAMPLINGRATE_16
SL_SAMPLINGRATE_22_05
SL_SAMPLINGRATE_24
SL_SAMPLINGRATE_32
SL_SAMPLINGRATE_44_1
SL_SAMPLINGRATE_48
SL_SAMPLINGRATE_64
SL_SAMPLINGRATE_88_2
SL_SAMPLINGRATE_96
SL_SAMPLINGRATE_192
</code></pre>
<p><br></p>
<h2 id="&#x64AD;&#x653E;&#x5668;"><a name="&#x64AD;&#x653E;&#x5668;" class="anchor-navigation-ex-anchor" href="#&#x64AD;&#x653E;&#x5668;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7. &#x64AD;&#x653E;&#x5668;</h2>
<pre><code class="lang-c++">SLObjectItf pcmPlayerObject = <span class="hljs-literal">NULL</span>;
<span class="hljs-comment">//&#x521B;&#x5EFA;&#x5BF9;&#x8C61;</span>
result = (*engineEngine)-&gt;CreateAudioPlayer(engineEngine, &amp;pcmPlayerObject, &amp;slDataSource, &amp;audioSnk, <span class="hljs-number">3</span>, ids, req);
<span class="hljs-comment">//&#x5B9E;&#x73B0;&#x5BF9;&#x8C61;</span>
(*pcmPlayerObject)-&gt;Realize(pcmPlayerObject, SL_BOOLEAN_FALSE);
<span class="hljs-comment">// &#x8DDF;&#x8FDB;&#x5BF9;&#x8C61;&#x83B7;&#x53D6; &#x64AD;&#x653E;&#x529F;&#x80FD;&#x63A5;&#x53E3;</span>
SLPlayItf pcmPlayerPlay = <span class="hljs-literal">NULL</span>;
(*pcmPlayerObject)-&gt;GetInterface(pcmPlayerObject, SL_IID_PLAY, &amp;pcmPlayerPlay);
<span class="hljs-comment">// &#x4F7F;&#x7528;&#x529F;&#x80FD;&#x63A5;&#x53E3;</span>
(*pcmPlayerPlay)-&gt;SetPlayState(pcmPlayerPlay,  SL_PLAYSTATE_PAUSED);
<span class="hljs-comment">//&#x83B7;&#x5F97; &#x97F3;&#x91CF;&#x63A5;&#x53E3;</span>
SLVolumeItf pcmPlayerVolume = <span class="hljs-literal">NULL</span>;
(*pcmPlayerObject)-&gt;GetInterface(pcmPlayerObject, SL_IID_VOLUME, &amp;pcmPlayerVolume);
</code></pre>
<p><br></p>
<h2 id="&#x4F7F;&#x7528;-opensl-es-&#x6D41;&#x7A0B;"><a name="&#x4F7F;&#x7528;-opensl-es-&#x6D41;&#x7A0B;" class="anchor-navigation-ex-anchor" href="#&#x4F7F;&#x7528;-opensl-es-&#x6D41;&#x7A0B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8. &#x4F7F;&#x7528; OPenSL ES &#x6D41;&#x7A0B;</h2>
<pre><code class="lang-c++"><span class="hljs-number">1</span>&#x3001;&#x521B;&#x5EFA;&#x63A5;&#x53E3;&#x5BF9;&#x8C61;
<span class="hljs-number">2</span>&#x3001;&#x8BBE;&#x7F6E;&#x6DF7;&#x97F3;&#x5668;
<span class="hljs-number">3</span>&#x3001;&#x521B;&#x5EFA;&#x64AD;&#x653E;&#x5668;&#xFF08;&#x5F55;&#x97F3;&#x5668;&#xFF09;
<span class="hljs-number">4</span>&#x3001;&#x8BBE;&#x7F6E;&#x7F13;&#x51B2;&#x961F;&#x5217;&#x548C;&#x56DE;&#x8C03;&#x51FD;&#x6570;
<span class="hljs-number">5</span>&#x3001;&#x8BBE;&#x7F6E;&#x64AD;&#x653E;&#x72B6;&#x6001;
<span class="hljs-number">6</span>&#x3001;&#x542F;&#x52A8;&#x56DE;&#x8C03;&#x51FD;&#x6570;
</code></pre>
<p><br></p>
<h2 id="androidstudio-&#x914D;&#x7F6E;-opengsl-es"><a name="androidstudio-&#x914D;&#x7F6E;-opengsl-es" class="anchor-navigation-ex-anchor" href="#androidstudio-&#x914D;&#x7F6E;-opengsl-es"><i class="fa fa-link" aria-hidden="true"></i></a>1.9. androidStudio &#x914D;&#x7F6E; opengSL ES</h2>
<pre><code class="lang-xml">1&#x3001;cmakelist&#x4E2D;&#x5F15;&#x5165;  OpenSLES   

2&#x3001;&#x5F15;&#x5165;&#x5934;&#x6587;&#x4EF6;
extern &quot;C&quot;
{
#include <span class="hljs-tag">&lt;<span class="hljs-name">SLES</span>/<span class="hljs-attr">OpenSLES.h</span>&gt;</span>
#include <span class="hljs-tag">&lt;<span class="hljs-name">SLES</span>/<span class="hljs-attr">OpenSLES_Android.h</span>&gt;</span>
};
</code></pre>
<p><br></p>
<h3 id="&#x58F0;&#x9053;&#x5207;&#x6362;"><a name="&#x58F0;&#x9053;&#x5207;&#x6362;" class="anchor-navigation-ex-anchor" href="#&#x58F0;&#x9053;&#x5207;&#x6362;"><i class="fa fa-link" aria-hidden="true"></i></a>1.9.1. &#x58F0;&#x9053;&#x5207;&#x6362;</h3>
<pre><code class="lang-xml">/*
   chan &#xFF1A; 0  &#x5DE6;&#x58F0;&#x9053; &#xFF0C;1 &#x53F3;&#x58F0;&#x9053;
   mute : true &#x5F00;&#x542F;&#x58F0;&#x9053;
   &#x7ACB;&#x4F53;&#x58F0;&#xFF1A;&#x5DE6;&#x58F0;&#x9053;&#x53F3;&#x58F0;&#x9053;&#x90FD;&#x5173;&#x95ED;
 */
 (*pcmMutePlay)-&gt;SetChannelMute(pcmMutePlay, 1, SL_BOOLEAN_FALSE);
 (*pcmMutePlay)-&gt;SetChannelMute(pcmMutePlay, 0, SL_BOOLEAN_TRUE);
</code></pre>
<p><br></p>
<h3 id="&#x6682;&#x505C;&#x3001;&#x64AD;&#x653E;"><a name="&#x6682;&#x505C;&#x3001;&#x64AD;&#x653E;" class="anchor-navigation-ex-anchor" href="#&#x6682;&#x505C;&#x3001;&#x64AD;&#x653E;"><i class="fa fa-link" aria-hidden="true"></i></a>1.9.2. &#x6682;&#x505C;&#x3001;&#x64AD;&#x653E;</h3>
<pre><code class="lang-xml">(*pcmPlayerPlay)-&gt;SetPlayState(pcmPlayerPlay,  SL_PLAYSTATE_PAUSED);

(*pcmPlayerPlay)-&gt;SetPlayState(pcmPlayerPlay,  SL_PLAYSTATE_PLAYING);
</code></pre>
<p><br></p>
<h3 id="seek-&#x4FEE;&#x6539;&#x64AD;&#x653E;&#x8FDB;&#x5EA6;"><a name="seek-&#x4FEE;&#x6539;&#x64AD;&#x653E;&#x8FDB;&#x5EA6;" class="anchor-navigation-ex-anchor" href="#seek-&#x4FEE;&#x6539;&#x64AD;&#x653E;&#x8FDB;&#x5EA6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.9.3. seek &#x4FEE;&#x6539;&#x64AD;&#x653E;&#x8FDB;&#x5EA6;</h3>
<p>&#x5BF9;&#x76F4;&#x64AD;&#x65E0;&#x6548;</p>
<pre><code class="lang-xml">int64_t rel = secds * AV_TIME_BASE;
avformat_seek_file(avFormatContext, -1, INT64_MIN, rel, INT64_MAX, 0);
</code></pre>
<p><br></p>
<h3 id="&#x4FEE;&#x6539;&#x97F3;&#x91CF;"><a name="&#x4FEE;&#x6539;&#x97F3;&#x91CF;" class="anchor-navigation-ex-anchor" href="#&#x4FEE;&#x6539;&#x97F3;&#x91CF;"><i class="fa fa-link" aria-hidden="true"></i></a>1.9.4. &#x4FEE;&#x6539;&#x97F3;&#x91CF;</h3>
<pre><code class="lang-xml"> SLmillibel level =50;
(*pcmVolumePlay)-&gt;SetVolumeLevel(pcmVolumePlay, level);
</code></pre>
<p><br></p>
<h3 id="&#x8FB9;&#x64AD;&#x8FB9;&#x5F55;"><a name="&#x8FB9;&#x64AD;&#x8FB9;&#x5F55;" class="anchor-navigation-ex-anchor" href="#&#x8FB9;&#x64AD;&#x8FB9;&#x5F55;"><i class="fa fa-link" aria-hidden="true"></i></a>1.9.5. &#x8FB9;&#x64AD;&#x8FB9;&#x5F55;</h3>
<pre><code class="lang-xml">&#x5229;&#x7528; Android&#xFF08;api&gt;=16&#xFF09;MediaCodec
&#x5C06;&#x539F;&#x59CB;&#x7684;PCM &#x6570;&#x636E; &#x7F16;&#x7801;&#x6210; AAC &#x683C;&#x5F0F;&#x7684;&#x6570;&#x636E; &#x76F4;&#x63A5;&#x4FDD;&#x5B58;&#x5373;&#x53EF;&#x3002;
</code></pre>
<p><br></p>
<h3 id="&#x6C42;pcm&#x7684;&#x5206;&#x8D1D;&#x503C;"><a name="&#x6C42;pcm&#x7684;&#x5206;&#x8D1D;&#x503C;" class="anchor-navigation-ex-anchor" href="#&#x6C42;pcm&#x7684;&#x5206;&#x8D1D;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.9.6. &#x6C42;PCM&#x7684;&#x5206;&#x8D1D;&#x503C;</h3>
<p><img src="https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201808151429_osChina_&#x5206;&#x8D1D;&#x8BA1;&#x7B97;&#x516C;&#x5F0F;.png" alt=""></p>
<pre><code class="lang-xml">Pref&#xFF1A;&#x5C31;&#x662F;&#x58F0;&#x97F3;&#x603B;&#x7684;&#x632F;&#x5E45;&#x6700;&#x5927;&#x503C;&#xFF1B;
Prms&#xFF1A;&#x5C31;&#x662F;&#x5F53;&#x524D;&#x58F0;&#x97F3;&#x7684;&#x632F;&#x5E45;&#x503C;&#xFF1B;
Lp&#xFF1A;&#x5C31;&#x662F;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x7684;&#x58F0;&#x97F3;&#x5206;&#x8D1D;&#x503C;&#x4E86;&#x3002;

&#x6839;&#x636E;&#x516C;&#x5F0F;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5F97;&#x77E5;&#x628A;&#x4E00;&#x6BB5;&#x65F6;&#x95F4;&#x7684;&#x632F;&#x5E45;&#x76F8;&#x52A0;&#x7136;&#x540E;&#x53BB;&#x5E73;&#x5747;&#x503C;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x5F97;&#x5230;&#x5F53;&#x524D;
&#x65F6;&#x95F4;&#x6BB5;&#x7684;&#x632F;&#x5E45;&#x503C;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x6C42;&#x51FA;&#x5206;&#x8D1D;&#x503C;&#x4E86;
</code></pre>
<footer class="page-footer"><span class="copyright">&#x65E0;&#x7248;&#x6743; &#x53EF;&#x4EE5;&#x65E0;&#x9650;&#x5236;&#x4F7F;&#x7528;&#xFF01; all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x66F4;&#x65B0;&#x65F6;&#x95F4;&#xFF1A;
2020-08-20 15:45:37
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../opencv/opencv.html" class="navigation navigation-prev " aria-label="Previous page: opencv">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="openSLES基础.html" class="navigation navigation-next " aria-label="Next page: openSLES基础">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"openSLES","level":"1.10","depth":1,"next":{"title":"openSLES基础","level":"1.10.1","depth":2,"path":"chinese/openSLES/openSLES基础.md","ref":"chinese/openSLES/openSLES基础.md","articles":[]},"previous":{"title":"opencv","level":"1.9.1","depth":2,"path":"chinese/opencv/opencv.md","ref":"chinese/opencv/opencv.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-plus","todo","anchor-navigation-ex","copy-code-button","versions-select","fontsettings","sharing","tbfed-pagefooter","donate","local-video","splitter","edit-link","expandable-chapters","favicon","theme-comscore","local-video"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"无版权 可以无限制使用！","modify_label":"该文件更新时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"todo":{},"splitter":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"versions-select":{"type":"branches"},"donate":{"alipay":"https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201803011956_osChina_支付宝收款码.png","alipayText":"支付宝打赏","button":"打赏","title":"","wechat":"https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201803011956_osChina_微信收款码.png","wechatText":"微信打赏"},"fontsettings":{"family":"sans","size":2,"theme":"sepia"},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":{"shortcut":"assets/images/favicon.ico","bookmark":"assets/images/favicon.ico"},"theme-comscore":{},"local-video":{},"copy-code-button":{},"versions":{"options":[{"value":"https://www.aivin666.cn/java_android/","text":"v1.0"}]},"sharing":{"all":["facebook","google","twitter","weibo","instapaper"],"facebook":false,"google":true,"instapaper":false,"twitter":false,"vk":false,"weibo":true},"edit-link":{"label":"托管页面","base":"https://www.baidu.com/"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"Aivin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Aivin开发笔记","language":"zh-hans","gitbook":"*","description":"Aivin开发笔记"},"file":{"path":"chinese/openSLES/openSLES基础.md","mtime":"2020-08-20T07:45:37.296Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-08-20T09:02:41.305Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-versions-select/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

